package com.example.service3;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @className: controller
 * @description:
 * @author: yang pan
 */
@RestController
@RefreshScope
public class Controller {
    @Value("${user.name}")
    private String userame;
    @Value("${user.mobile}")
    private String mobile;


    @Autowired
    private DiscoveryClient discoveryClient;

    @RequestMapping("/getServices")
    public List<String>  getServices(){
        List<String> services = discoveryClient.getServices();
        return services;
    }
    @RequestMapping("/getinstances")
    public List<ServiceInstance>  getinstances(){
        List<ServiceInstance> serviceList = discoveryClient.getInstances("service1");
        ServiceInstance serviceInstance = serviceList.get(0);
        return serviceList;
    }


}
